package uk.ac.ebi.microarray.expressionprofiler.ra;

import javax.resource.ResourceException;
import javax.resource.spi.ActivationSpec;
import javax.resource.spi.BootstrapContext;
import javax.resource.spi.ResourceAdapter;
import javax.resource.spi.ResourceAdapterInternalException;
import javax.resource.spi.endpoint.MessageEndpointFactory;
import javax.resource.spi.work.WorkManager;
import javax.transaction.xa.XAResource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class AEEPResourceAdapter implements ResourceAdapter {

    public final static String JNDI_NAME = "java:comp/env/ra/AE_EPAdapter";

    private BootstrapContext context;

    private final Log log = LogFactory.getLog(AEEPResourceAdapter.class);

    public void start(@SuppressWarnings("hiding")
    BootstrapContext context) throws ResourceAdapterInternalException {
        log.info("start");
        this.context = context;
    }

    public void stop() {
        log.info("stop");
    }

    public void endpointActivation(MessageEndpointFactory arg0, ActivationSpec arg1) throws ResourceException {
        log.info("endpointActivation");
    }

    public void endpointDeactivation(MessageEndpointFactory arg0, ActivationSpec arg1) {
        log.info("endpointDeactivation");
    }

    public XAResource[] getXAResources(ActivationSpec[] arg0) throws ResourceException {
        log.info("getXAResources");
        return null;
    }

    public WorkManager getWorkManager() {
        return context.getWorkManager();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof AEEPResourceAdapter) {
            return true;
        }
        return false;
    }

}
